package com.cat.dataStructure;

import java.util.PriorityQueue;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/minimum-operations-to-exceed-threshold-value-ii/description/
 * @create 2025/10/4 21:12
 * @since JDK17
 */

public class Solution95 {
    public int minOperations(int[] nums, int k) {
        PriorityQueue<Long> heap = new PriorityQueue<>();
        int ans = 0;
        for (long num : nums) {
            heap.add(num);
        }
        while (true) {
            long m1 = heap.poll();
            if (m1 >= k) {
                return ans;
            }
            long m2 = heap.poll();
            heap.add(m1 * 2 + m2);
            ans++;
        }
    }
}
